package com.wpl.user.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wpl.user.entity.User;
import com.wpl.user.mapper.UserMapper;
import com.wpl.user.service.UserService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wpl
 * @since 2023-11-24
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public Integer login(User user) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("name",user.getName())
                .eq("email",user.getEmail());
        List<User> list = this.list(wrapper);

        if (list != null && list.size() != 0) return  list.get(0).getId();
        return -1;
    }
}
// basemapper有的 service也有 也只有自己写的时候用mapper